/*
 * @Description:
 * @Author: cgt
 * @Date: 2021-12-23 14:05:56
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 18:54:00
 */
/**
 * 鼠标指针式样控制工具
 */
class CursorUtil {
  constructor(_map) {
    this.map = _map;
    this.currentCursor = null;
  }

  /**
   * 更改鼠标指针式样
   * @param {String} type 鼠标指针式样
   */
  changeCursor(type) {
    if (this.currentCursor) {
      if (this.currentCursor !== type) {
        this.map.getContainer().classList.remove('mouse-' + this.currentCursor);
        this.map.getContainer().classList.add('mouse-' + type);
        this.currentCursor = type;
      }
    } else {
      this.map.getContainer().classList.add('mouse-' + type);
      this.currentCursor = type;
    }
  }

  /**
   * 重置鼠标指针式样
   */
  reset() {
    this.map.getContainer().classList.remove('mouse-' + this.currentCursor);
    this.currentCursor = null;
  }
}

export default CursorUtil;
